using System;
using Microsoft.EntityFrameworkCore.Migrations;

namespace DynamicModelDemo.Migrations
{
    public partial class InitialStudent : Migration
    {
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            for (int i = 0; i < 2; i++)
            {
                string date = DateTime.Now.AddDays(i).ToString("yyyy-MM-dd");
                migrationBuilder.CreateTable(
                name: $"students-{date}",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
                    Name = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    ExtraProperties = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    CreationTime = table.Column<DateTime>(type: "datetime2", nullable: false),
                    CreatorId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
                    LastModificationTime = table.Column<DateTime>(type: "datetime2", nullable: true),
                    LastModifierId = table.Column<Guid>(type: "uniqueidentifier", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey($"PK_students-{date}", x => x.Id);
                });
            }
        }

        protected override void Down(MigrationBuilder migrationBuilder)
        {
            for (int i = 0; i < 2; i++)
            {
                string date = DateTime.Now.AddDays(i).ToString("yyyy-MM-dd");
                migrationBuilder.DropTable(
                     name: $"students-{date}");
            }
        }
    }
}
